import React from "react";
import { Button } from "antd";
import classNames from 'classnames';
import { Consumer } from "../../theme";
import { WeaLocaleProvider } from "ecCom";
import './index.less';

const getLabel = WeaLocaleProvider.getLabel;
const formatMultiLang = WeaLocaleProvider.formatMultiLang;

export default class FBFooterView extends React.Component {
  render() {
    const { data, onSubmit, loading, disable, ...props } = this.props;
    const clsNameStr = classNames('wea-edc-form-btn', {
      'btn-disable': loading || disable
    });

    return (
      <Consumer ecId={`${this && this.props && this.props.ecId || ''}_Consumer@1yg00y`}>
        {({ submitBtn = { textAlign: 'left', css: {} } }) => (
          <div className='wev-edc-form-footer__view' {...props} style={{ textAlign: submitBtn.textAlign }}>
            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@gls84l`}
              type='primary'
              icon={loading && !disable && 'loading'}
              className={clsNameStr}
              onClick={() => onSubmit()}
              style={submitBtn.css}
            >
              {formatMultiLang(data.btnText)}
            </Button>
          </div>
        )}
      </Consumer>
    );
  }
}

FBFooterView.defaultProps = {
  data: {
    btnText: getLabel('502502', '提交')
  },
  onSubmit: () => { }
};